const { is } = require("core-js/core/object")

module.exports = (api) => {
    // 实现csr ssr
    const isWeb = api.caller(caller => caller && caller.target === 'web')

    return {
        presets: [
            [
                '@babel/env',
                {
                    corejs: isWeb ? 3 : false,
                    useBuiltIns: isWeb ? 'usage' : undefined,
                },
            ],
            '@babel/typescript',
            [
                '@babel/preset-react',
                {
                    runtime: 'automatic',
                },
            ]
        ],
        plugins: [
            '@loadable/babel-plugin',
            '@babel/plugin-transform-runtime',
        ],
        env: {
            development: {
                plugins: isWeb ? ['react-refresh/babel'] : undefined,
            }
        }
    }
}